<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<fmt:setBundle basename="ApplicationMessage" />

<!DOCTYPE html>
<html lang="zh-CN">
<head>

  <%@ include file="/WEB-INF/include/meta.jsp"%>
  <%@ include file="/WEB-INF/include/css.jsp"%>
  
</head>

<body class="ihg-theme-draft">

  <%@ include file="/WEB-INF/include/header.jsp"%>
  <jsp:include page="/WEB-INF/include/submenu-session.jsp">
    <jsp:param name="currentUrl" value="${ctx.host}/sessions/${session.id}" />
  </jsp:include>

  <div class="container-fluid ihg-container has-ihg-sidemenu">

    <div class="ihg-content-layout has-operation">

      <div class="ihg-breadcrumb">
        <ol class="breadcrumb border-breadcrumb  no-bottom-border">
          <li class="active">Final Report</li>
        </ol>
      </div>
      
      <div class="ihg-content-layout has-operation">
        <div class="ihg-operation-bar no-margin no-bottom-border clearfix">
          <div class="ihg-operation-group pull-right">
            <a href="${ctx.host}/sessions/${session.id}/final-reports/batch-ppl-report" class="btn btn-success btn-shadow btn-shadow-success" data-target="#manager-report" data-toggle="modal">批量PPL报告</a>
            <a href="${ctx.host}/sessions/${session.id}/final-reports/batch-manager-report" class="btn btn-success btn-shadow btn-shadow-success" data-target="#manager-report" data-toggle="modal">批量经理报告</a>
            <a href="${ctx.host}/sessions/${session.id}/final-reports/batch-delegate-report" class="btn btn-success btn-shadow btn-shadow-success" data-target="#manager-report" data-toggle="modal">批量学员报告</a>
            <a href="${ctx.host}/sessions/${session.id}/final-reports/delegate-report-batch-send" class="btn btn-success btn-shadow btn-shadow-success" data-target="#manager-report" data-toggle="modal">批量发送学员</a>
            <a href="${ctx.host}/sessions/${session.id}/final-reports/manager-report-batch-send" class="btn btn-success btn-shadow btn-shadow-success" data-target="#manager-report" data-toggle="modal">批量发送经理</a>
          </div>
        </div>
        
        <table class="table ihg-table peer-calibration-table" style="border-bottom: 1px solid #D45F16; margin-top: 10px;">
          <thead style="border-top: 2px solid #D45F16;">
            <tr>
              <th style="min-width: 330px; text-align: left;"><fmt:message key="assessor.377" /></th>
              <th style="max-width: 100px; text-align: left;"><fmt:message key="assessor.378-1" /></th>
              <th style="max-width: 140px; text-align: center;"><fmt:message key="assessor.379-1" /></th>
              <th style="max-width: 100px; text-align: center;"><fmt:message key="assessor.380-1" /></th>
              <th style="width: 250px;"><fmt:message key="assessor.381-1" /></th>
              <th style="width: 250px;"><fmt:message key="assessor.381-2" /></th>
            </tr>
          </thead>
          
          <tbody>
            <c:forEach var="sessionCalibration" items="${sessionCalibrations}">
              <tr>
                <td>
                  <div class="delegate-avater" style="background-color: #F4F2ED; display: inline-block; width: 100px; height: 100px; vertical-align: middle;"><img src="${sessionCalibration.delegate.avatar}"></div>
                  <div class="delegate-information text-left" style="width: 185px; display: inline-block; margin-left: 10px; vertical-align: middle;">
                    <strong><fmt:message key="assessor.382" /> ${sessionCalibration.delegate.name}</strong>
                    <p><fmt:message key="assessor.238" />${sessionCalibration.delegate.telephone}<br></p><br>
                    <strong><fmt:message key="assessor.384" />：${sessionCalibration.leadAssessor.name}</strong>
                    <p><fmt:message key="assessor.238" /> ${sessionCalibration.leadAssessor.telephone}</p>
                  </div>
                </td>
                <td style="text-align: left;">
                  <span class="label label-${empty reportWritings[sessionCalibration.idString] or reportWritings[sessionCalibration.idString].status.created ? 'default' : reportWritings[sessionCalibration.idString].status.editing ? 'danger' : 'success'} delegate-label" style="width:115px;">
                    ${empty reportWritings[sessionCalibration.idString] or reportWritings[sessionCalibration.idString].status.created ? '未修改' : reportWritings[sessionCalibration.idString].status.editing ? 'super已修改' : 'admin已修改'}
                  </span>
                </td>
                <td style="text-align: center;">
                  <c:choose>
                    <c:when test="${reportTaskStatus[sessionCalibration.delegate.id].finish && not empty reportWritings[sessionCalibration.idString]}">
                      <a href="${ctx.host}/sessions/${session.id}/final-reports/${sessionCalibration.id}/report-writing" class="btn btn-default" style="width: 140px;background: ${reportWritings[sessionCalibration.idString].status.finish ? '#5cb85c' : '#3CAED6'}; color: #fff;"> <fmt:message key="assessor.385-4" />&nbsp;&nbsp;<fmt:message key="assessor.385-2" /></a>
                    </c:when>
                    <c:otherwise>
                      <a href="javascript:void(0);">
                        <img src="${ctx.resource}/images/calibration-to-be-completed.png">
                      </a>
                    </c:otherwise>
                  </c:choose>
                </td>
                <td  style="text-align: center;">
                  <c:choose>
                    <c:when test="${empty sessionReports[sessionCalibration.delegate.idString] or empty sessionReports[sessionCalibration.delegate.idString].waveReport}">
                      <a href="javascript:void(0);" class="btn btn-default" style="width: 90px; color: #999; background-color: #f8f7f7; opacity: 1;" disabled>未上传</a>
                    </c:when>
                    <c:otherwise>
                      <a href="${sessionReports[sessionCalibration.delegate.idString].waveReport}" class="btn btn-default" style="width: 90px;background: #3CAED6; color: #fff;" download="">下载</a>
                    </c:otherwise>
                  </c:choose>
                </td>
                <td>
                  <c:choose>
                    <c:when test="${not empty sessionReports[sessionCalibration.delegate.idString] && not empty sessionReports[sessionCalibration.delegate.idString].managerFinalReport}">
                      <a href="${sessionReports[sessionCalibration.delegate.idString].managerFinalReport}" download="" class="btn btn-default" style="width: 150px; color: #999; margin-bottom:10px; background-color: #f8f7f7; opacity: 1;" >经理报告已生成</a>
                    </c:when>
                    <c:when test="${not empty sessionReports[sessionCalibration.delegate.idString] && sessionReports[sessionCalibration.delegate.idString].managerFinalReportStatus.generating}">
                      <a href="javascript:void(0);" style="width: 150px; margin-bottom: 10px; background: #d9534f; color: #fff;" class="btn btn-default">经理报告生成中</a>
                    </c:when>
                    <c:otherwise>
                      <a href="${ctx.host}/sessions/${session.id}/final-reports/${sessionCalibration.id}/manager-report" class="btn btn-success" style="width: 150px; margin-bottom: 10px; background: #3CAED6; color: #fff;" data-toggle="modal" data-target="#manager-report">经理报告</a>
                    </c:otherwise>
                  </c:choose>
                  <c:choose>
                    <c:when test="${not empty sessionReports[sessionCalibration.delegate.idString] && not empty sessionReports[sessionCalibration.delegate.idString].peoplePlaningFinalReport}">
                      <a href="${sessionReports[sessionCalibration.delegate.idString].peoplePlaningFinalReport}" download="" class="btn btn-default" style="width: 150px; color: #999; margin-bottom:10px; background-color: #f8f7f7; opacity: 1;" >PPL报告已生成</a>
                    </c:when>
                    <c:when test="${not empty sessionReports[sessionCalibration.delegate.idString] && sessionReports[sessionCalibration.delegate.idString].peoplePlaningFinalReportStatus.generating}">
                      <a href="javascript:void(0);" style="width: 150px; margin-bottom: 10px; background: #d9534f; color: #fff;" class="btn btn-default">PPL报告生成中</a>
                    </c:when>
                    <c:otherwise>
                      <a href="${ctx.host}/sessions/${session.id}/final-reports/${sessionCalibration.id}/ppl-report" class="btn btn-success" style="width: 150px; margin-bottom: 10px; background: #3CAED6; color: #fff;" data-toggle="modal" data-target="#ppl-report">PPL报告</a>
                    </c:otherwise>
                  </c:choose>
                  <c:choose>
                    <c:when test="${not empty sessionReports[sessionCalibration.delegate.idString] && sessionReports[sessionCalibration.delegate.idString].delegateFinalReportStatus.generating}">
                      <a href="javascript:void(0);" style="width: 150px; margin-bottom: 10px; background: #d9534f; color: #fff;" class="btn btn-default">学员报告生成中</a>
                    </c:when>
                    <c:when test="${not empty sessionReports[sessionCalibration.delegate.idString] && not empty sessionReports[sessionCalibration.delegate.idString].waveDelegateReport && not empty sessionReports[sessionCalibration.delegate.idString].managerFinalReport && empty sessionReports[sessionCalibration.delegate.idString].delegateFinalReport}">
                      <a href="${ctx.host}/sessions/${session.id}/final-reports/${sessionCalibration.id}/delegate-report" class="btn btn-success" style="width: 150px; background: #3CAED6; color: #fff;" data-toggle="modal" data-target="#delegate-report">学员报告</a>
                    </c:when>
                    <c:when test="${not empty sessionReports[sessionCalibration.delegate.idString] && not empty sessionReports[sessionCalibration.delegate.idString].waveDelegateReport && not empty sessionReports[sessionCalibration.delegate.idString].managerFinalReport && not empty sessionReports[sessionCalibration.delegate.idString].delegateFinalReport}">
                      <a href="${sessionReports[sessionCalibration.delegate.idString].delegateFinalReport}" download="" class="btn btn-default" style="width: 150px; color: #999; margin-bottom:10px; background-color: #f8f7f7; opacity: 1;">学员报告已生成</a>
                    </c:when>
                    <c:otherwise>
                      <a href="javascript:void(0);" class="btn btn-default" style="width: 150px; color: #999; background-color: #f8f7f7; opacity: 1;" data-toggle="modal" data-target="#delegate-report" disabled>学员报告</a>
                    </c:otherwise>
                  </c:choose>
                </td>
                <td>
                  <c:set var="sessionReport" value="${sessionReports[sessionCalibration.delegate.idString]}" />
                  <c:choose>
                    <c:when test="${(not empty sessionReport) and empty sessionReport.delegateFinalReport}">
                      <a href="javascript:void(0);" class="btn btn-default" style="width: 150px; color: #999; margin-bottom:10px; background-color: #f8f7f7; opacity: 1;" disabled>学员报告暂未生成</a>
                    </c:when>
                    <c:when test="${(not empty sessionReport) and sessionReport.delegateSendStatus.unsent}">
                      <a href="${ctx.host}/sessions/${session.id}/final-reports/${sessionCalibration.id}/delegate-report-send" class="btn btn-default" style="width: 150px; margin-bottom: 10px; background: #3CAED6; color: #fff;" data-toggle="modal" data-target="#delegate-report-send">发送学员</a><br/>
                    </c:when>
                    <c:when test="${(not empty sessionReport) and sessionReport.delegateSendStatus.sending}">
                      <a href="javascript:void(0);" style="width: 150px; margin-bottom: 10px; background: #d9534f; color: #fff;" class="btn btn-default">发送学员&nbsp;&nbsp;<span class="glyphicon glyphicon-send"></span></a>
                    </c:when>
                    <c:when test="${(not empty sessionReport) and sessionReport.delegateSendStatus.sent}">
                      <a href="javascript:void(0);" class="btn btn-default" style="width: 150px; color: #999; margin-bottom:10px; background-color: #f8f7f7; opacity: 1;" disabled>已发送学员</a>
                    </c:when>
                  </c:choose>
                  
                  <c:choose>
                    <c:when test="${(not empty sessionReport) and empty sessionReport.managerFinalReport}">
                      <a href="javascript:void(0);" class="btn btn-default" style="width: 150px; color: #999; margin-bottom:10px; background-color: #f8f7f7; opacity: 1;" disabled>经理报告暂未生成</a>
                    </c:when>
                    <c:when test="${(not empty sessionReport) and sessionReport.managerSendStatus.unsent}">
                      <a href="${ctx.host}/sessions/${session.id}/final-reports/${sessionCalibration.id}/manager-report-send" class="btn btn-default" style="width: 150px; background: #3CAED6; color: #fff;" data-toggle="modal" data-target="#manager-report-send">发送经理</a><br/>
                    </c:when>
                    <c:when test="${(not empty sessionReport) and sessionReport.managerSendStatus.sending}">
                      <a href="javascript:void(0);" style="width: 150px; background: #d9534f; color: #fff;" class="btn btn-default">发送经理&nbsp;&nbsp;<span class="glyphicon glyphicon-send"></span></a><br/>
                    </c:when>
                    <c:when test="${(not empty sessionReport) and sessionReport.managerSendStatus.sent}">
                      <a href="javascript:void(0);" class="btn btn-default" style="width: 150px; color: #999; margin-bottom:10px; background-color: #f8f7f7; opacity: 1;" disabled>已发送经理</a>
                    </c:when>
                  </c:choose>
                </td>
              </tr>
            </c:forEach>
          </tbody>
        </table>
      </div>

    </div>
  </div>
  
  <%@ include file="/WEB-INF/include/footer.jsp"%>
  <%@ include file="/WEB-INF/include/script.jsp"%>
  <d:resource root="${ctx.resource}/build" type="script" src="js/page/session/during/final-report/final-report-list.js" />
  <script type="text/javascript">
    require([ 'page/session/during/final-report/final-report-list' ], function(page) {
      page.init();
    })
  </script>

</body>
</html>